#####################################################################################
####
####  Appendix Graphs
####
#####################################################################################


library (foreign)




###########################################################
####   Dichotomous Measure of Birth Legacy
###########################################################



## War
# Laptop
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Selection/PostEstimation/SimWarProb.dta")


## Interstate War
# Laptop
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Selection/PostEstimation/SimISWarProb.dta")



## Civil War
# Laptop
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Selection/PostEstimation/SimCWarProb.dta")



op <- par(mfrow = c(1,3), oma=c(5,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.07),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.03,.06))
mtext("Pr(Win|Good Birth) - Pr(Win|Bad Birth)", side=2,line=3,cex=.75)
mtext("Years Since Last War", side=1,line=3,cex=.75)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.07),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.03,.06))
mtext("Years Since Last Interstate War", side=1,line=3,cex=.75)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.07),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.03,.06))
mtext("Years Since Last Civil War", side=1,line=3,cex=.75)



}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.15, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black","gray"),
        lty=c(2,-1),pch=c(-1,15),ncol=1)




###########################################################
####   Trichotomous Measure of Birth Legacy
###########################################################



## War
# Laptop
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Selection/PostEstimation/SimWarProb.dta")


## Interstate War
# Laptop
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Selection/PostEstimation/SimISWarProb.dta")



## Civil War
# Laptop
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Selection/PostEstimation/SimCWarProb.dta")



op <- par(mfrow = c(1,3), oma=c(5,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.07),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.03,.06))
mtext("Pr(Win|Good Birth) - Pr(Win|Bad Birth)", side=2,line=3,cex=.75)
mtext("Years Since Last War", side=1,line=3,cex=.75)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.07),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.03,.06))
mtext("Years Since Last Interstate War", side=1,line=3,cex=.75)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.07),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.03,.06))
mtext("Years Since Last Civil War", side=1,line=3,cex=.75)



}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.15, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black","gray"),
        lty=c(2,-1),pch=c(-1,15),ncol=1)






########################################
##  Sartori Figures
########################################


## Good
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SartoriPostEstimation/SimWarGoodProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SartoriPostEstimation/SimISWarGoodProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SartoriPostEstimation/SimCWarGoodProb.dta")


postscript("SartoriGood.eps",horizontal=FALSE,height=7,width=7)

op <- par(mfrow = c(1,3), oma=c(5,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.05),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col="gray", border=NA)
lines(warprob$ruler,warprob$diff_hat,type="l",lty=1,lwd=2,col="black")
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Pr(Win|Good Birth) - Pr(Win|Bad Birth)", side=2,line=3,cex=.75)
mtext("Years Since Last War", side=1,line=3,cex=.75)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.05),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col="gray", border=NA)
lines(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=1,lwd=2,col="black")
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Years Since Last Interstate War", side=1,line=3,cex=.75)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.05),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col="gray", border=NA)
lines(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=1,lwd=2,col="black")
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Years Since Last Civil War", side=1,line=3,cex=.75)



}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.15, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black","gray"),
        lty=c(1,-1),pch=c(-1,15),ncol=1)


dev.off()






## Legacy
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SartoriPostEstimation/SimWarLegacyProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SartoriPostEstimation/SimISWarLegacyProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SartoriPostEstimation/SimCWarLegacyProb.dta")


postscript("SartoriLegacy.eps",horizontal=FALSE,height=7,width=7)

op <- par(mfrow = c(1,3), oma=c(5,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.05),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col="gray", border=NA)
lines(warprob$ruler,warprob$diff_hat,type="l",lty=1,lwd=2,col="black")
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Pr(Win|Good Birth) - Pr(Win|Bad Birth)", side=2,line=3,cex=.75)
mtext("Years Since Last War", side=1,line=3,cex=.75)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.05),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col="gray", border=NA)
lines(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=1,lwd=2,col="black")
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Years Since Last Interstate War", side=1,line=3,cex=.75)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.05),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col="gray", border=NA)
lines(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=1,lwd=2,col="black")
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Years Since Last Civil War", side=1,line=3,cex=.75)


}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.15, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black","gray"),
        lty=c(1,-1),pch=c(-1,15),ncol=1)

dev.off()






## Legacy22
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SartoriPostEstimation/SimWarLegacy22Prob.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SartoriPostEstimation/SimISWarLegacy22Prob.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SartoriPostEstimation/SimCWarLegacy22Prob.dta")

postscript("SartoriLegacy22.eps",horizontal=FALSE,height=7,width=7)


op <- par(mfrow = c(1,3), oma=c(5,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.05),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col="gray", border=NA)
lines(warprob$ruler,warprob$diff_hat,type="l",lty=1,lwd=2,col="black")
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Pr(Win|Good Birth) - Pr(Win|Bad Birth)", side=2,line=3,cex=.75)
mtext("Years Since Last War", side=1,line=3,cex=.75)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.05),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col="gray", border=NA)
lines(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=1,lwd=2,col="black")
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Years Since Last Interstate War", side=1,line=3,cex=.75)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.05),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col="gray", border=NA)
lines(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=1,lwd=2,col="black")
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Years Since Last Civil War", side=1,line=3,cex=.75)


}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.15, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black","gray"),
        lty=c(1,-1),pch=c(-1,15),ncol=1)


dev.off()







#################################################
### Competing Risks/Multinomial Logit Models
#################################################



WarProb <- read.dta("C:/Users/Jeff Carter/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/MNL/PostEstimation/WarProbMNL.dta")
ISWarProb <- read.dta("C:/Users/Jeff Carter/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/MNL/PostEstimation/ISWarProbMNL.dta")
CWarProb <- read.dta("C:/Users/Jeff Carter/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/MNL/PostEstimation/CWarProbMNL.dta")




ruler <- WarProb$ruler

########################################


## Graph of Difference in War Onset and Winning a War for Good and Bad Birth States


op <- par(mfrow = c(1,3),oma=c(6,2,0,0))
{


plot(ruler,WarProb$diff1,type="l",lwd=2,col="red",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(ruler, rev(ruler)),
        y = c(WarProb$diff1lo, rev(WarProb$diff1hi)),
        col=rgb(1,.25,0,.25), border=NA)
lines(ruler,WarProb$diff3,type="l",lty=3,lwd=2,col="blue")
polygon(x=c(ruler, rev(ruler)),
        y = c(WarProb$diff3lo, rev(WarProb$diff3hi)),
        col=rgb(0,.25,1,.25), border=NA)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.1, 0.2))
abline(h=0,col="black",lty=1)
mtext("Pr(Good Birth)-Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column A: War", side=3,line=2,cex=1.25)




plot(ruler,ISWarProb$diff1,type="l",lwd=2,col="red",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(ruler, rev(ruler)),
        y = c(ISWarProb$diff1lo, rev(ISWarProb$diff1hi)),
        col=rgb(1,.25,0,.25), border=NA)
lines(ruler,ISWarProb$diff3,type="l",lty=3,lwd=2,col="blue")
polygon(x=c(ruler, rev(ruler)),
        y = c(ISWarProb$diff3lo, rev(ISWarProb$diff3hi)),
        col=rgb(0,.25,1,.25), border=NA)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-0.1, 0,0.1, 0.2))
abline(h=0,col="black",lty=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column B: Interstate War", side=3,line=2,cex=1.25)


plot(ruler,CWarProb$diff1,type="l",lwd=2,col="red",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(ruler, rev(ruler)),
        y = c(CWarProb$diff1lo, rev(CWarProb$diff1hi)),
        col=rgb(1,.25,0,.25), border=NA)
lines(ruler,CWarProb$diff3,type="l",lty=3,lwd=2,col="blue")
polygon(x=c(ruler, rev(ruler)),
        y = c(CWarProb$diff3lo, rev(CWarProb$diff3hi)),
        col=rgb(0,.25,1,.25), border=NA)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-0.1,0,0.1, 0.2))
abline(h=0,col="black",lty=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column C: Civil War", side=3,line=2,cex=1.25)

}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1.75,-.2, c("Win a War","Peace","95% Confidence Interval","95% Confidence Interval"), bty="n", cex=1,col=c("red","blue",rgb(1,.25,0,.25),rgb(0,.25,1,.25)),
        lty=c(1,2,-1,-1),pch=c(-1,-1,15,15),ncol=2)












plot(ruler,diff1,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(ruler, rev(ruler)),
        y = c(diff1lo, rev(diff1hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.05,.1))
mtext("Pr(War|Good Birth) - Pr(War|Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Birth Legacy and War Onset", side=3,line=2,cex=1.25)








## Probabilities for Good Birth State



plot(ruler,WarProb$pr11,type="l",lwd=2,col="red",ylim=c(0,1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(ruler, rev(ruler)),
        y = c(WarProb$lo11, rev(WarProb$hi11)),
        col=rgb(1,.25,0,.25), border=NA)
lines(ruler,WarProb$pr21,lty="dashed",lwd=2,col="blue")
polygon(x=c(ruler, rev(ruler)),
        y = c(WarProb$lo21, rev(WarProb$hi21)),
        col=rgb(0,.25,1,.25), border=NA)
lines(ruler,WarProb$pr31,type="l",lty=3,lwd=2,col="black")
polygon(x=c(ruler, rev(ruler)),
        y = c(WarProb$lo31, rev(WarProb$hi31)),
        col=rgb(.5,.5,.5,.25), border=NA)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.1, 0.2))
mtext("Pr(War Onset)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Birth Legacy and War Onset", side=3,line=2,cex=1.25)



## Probabilities for Onset and Win for Good and Bad Birth States



plot(ruler,WarProb$pr11,type="l",lwd=2,col="red",ylim=c(0,1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(ruler, rev(ruler)),
        y = c(WarProb$lo11, rev(WarProb$hi11)),
        col=rgb(1,.25,0,.25), border=NA)
lines(ruler,WarProb$pr10,lty="dashed",lwd=2,col="blue")
polygon(x=c(ruler, rev(ruler)),
        y = c(WarProb$lo10, rev(WarProb$hi10)),
        col=rgb(0,.25,1,.25), border=NA)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.1, 0.2))
mtext("Pr(War Win)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Birth Legacy and War Win", side=3,line=2,cex=1.25)



lines(ruler,WarProb$pr31,type="l",lty=3,lwd=2,col="black")
polygon(x=c(ruler, rev(ruler)),
        y = c(WarProb$lo31, rev(WarProb$hi31)),
        col=rgb(.5,.5,.5,.25), border=NA)















###########################################################
####   Age Interaction
###########################################################




## Legacy
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/AgeInteraction/War/SimWarProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/AgeInteraction/ISWar/SimISWarProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/AgeInteraction/CWar/SimCWarProb.dta")



op <- par(mfrow = c(2,3), oma=c(4,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diffI_hat,type="l",lty=1,lwd=2,col="blue",ylim=c(-.1,.1),xlim=c(0,200),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diffI_lo, rev(warprob$diffI_hi)),
        col=rgb(0,.25,1,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,50,100,150,200))
axis(2, at=c(-.1,0,.1))
mtext("Pr(Good Birth) - Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Column A: War", side=3,line=2,cex=1)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diffI_hat,type="l",lty=1,lwd=2,col="blue",ylim=c(-.1,.1),xlim=c(0,200),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diffI_lo, rev(iswarprob$diffI_hi)),
        col=rgb(0,.25,1,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,50,100,150,200))
axis(2, at=c(-.1,0,.1))
mtext("Column B: Interstate War", side=3,line=2,cex=1)


#### Civil War

plot(cwarprob$ruler,cwarprob$diffI_hat,type="l",lty=1,lwd=2,col="blue",ylim=c(-.1,.1),xlim=c(0,200),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diffI_lo, rev(cwarprob$diffI_hi)),
        col=rgb(0,.25,1,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,50,100,150,200))
axis(2, at=c(-.1,0,.1))
mtext("Column C: Civil War", side=3,line=2,cex=1)

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=2,lwd=2,col="red",ylim=c(-.1,.1),xlim=c(0,200),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(1,.25,0,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,50,100,150,200))
axis(2, at=c(-.1,0,.1))
mtext("Pr(Good Birth) - Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Birth", side=1,line=3,cex=1)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=2,lwd=2,col="red",ylim=c(-.1,.1),xlim=c(0,200),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(1,.25,0,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,50,100,150,200))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Birth", side=1,line=3,cex=1)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=2,lwd=2,col="red",ylim=c(-.1,.1),xlim=c(0,200),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(1,.25,0,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,50,100,150,200))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Birth", side=1,line=3,cex=1)

}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1.5,-.4, c("War Participation","Win War","95% Confidence Interval","95% Confidence Interval"), bty="n", cex=1,col=c("blue","red",rgb(0,.25,1,.25),rgb(1,.25,0,.25)),
        lty=c(1,2,-1,-1),pch=c(-1,-1,15,15),ncol=2)






###########################################################
####   Regime Type
###########################################################




## Legacy
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/Polity/War/SimWarProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/Polity/ISWar/SimISWarProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/Polity/CWar/SimCWarProb.dta")



op <- par(mfrow = c(1,3), oma=c(4,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Pr(Good Birth) - Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column A:  War", side=3,line=2,cex=1)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column B: Interstate War", side=3,line=2,cex=1)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column C: Civil War", side=3,line=2,cex=1)

}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1.75,-.175, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black",rgb(.25,.25,.25,.25)),
        lty=c(1,-1),pch=c(-1,15),ncol=2)







###########################################################
####  CINC Scores
###########################################################




## Legacy
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/CINC/War/SimWarProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/CINC/ISWar/SimISWarProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/CINC/CWar/SimCWarProb.dta")



op <- par(mfrow = c(1,3), oma=c(4,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Pr(Good Birth) - Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column A:  War", side=3,line=2,cex=1)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column B: Interstate War", side=3,line=2,cex=1)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column C: Civil War", side=3,line=2,cex=1)

}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1.75,-.175, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black",rgb(.25,.25,.25,.25)),
        lty=c(1,-1),pch=c(-1,15),ncol=2)






## Polity and CINC

## Good
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SelectionPostEstimation/SimWarGoodProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SelectionPostEstimation/SimISWarGoodProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SelectionPostEstimation/SimCWarGoodProb.dta")


##### Joint Probabilities

####  War

op <- par(mfrow = c(1,3), oma=c(5,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.04),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Pr(Win|Good Birth) - Pr(Win|Bad Birth)", side=2,line=3,cex=.75)
mtext("Years Since Last War", side=1,line=3,cex=.75)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.04),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Years Since Last Interstate War", side=1,line=3,cex=.75)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.04),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Years Since Last Civil War", side=1,line=3,cex=.75)



}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.15, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black","gray"),
        lty=c(2,-1),pch=c(-1,15),ncol=1)





## Legacy
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SelectionPostEstimation/SimWarLegacyProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SelectionPostEstimation/SimISWarLegacyProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SelectionPostEstimation/SimCWarLegacyProb.dta")


##### Joint Probabilities

####  War

op <- par(mfrow = c(1,3), oma=c(5,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.04),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Pr(Win|Good Birth) - Pr(Win|Bad Birth)", side=2,line=3,cex=.75)
mtext("Years Since Last War", side=1,line=3,cex=.75)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.04),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Years Since Last Interstate War", side=1,line=3,cex=.75)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.04),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Years Since Last Civil War", side=1,line=3,cex=.75)



}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.15, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black","gray"),
        lty=c(2,-1),pch=c(-1,15),ncol=1)








## Legacy22
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SelectionPostEstimation/SimWarLegacy22Prob.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SelectionPostEstimation/SimISWarLegacy22Prob.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D2/Analysis/Models/Appendix/SelectionPostEstimation/SimCWarLegacy22Prob.dta")



##### Joint Probabilities

####  War

op <- par(mfrow = c(1,3), oma=c(5,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.04),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Pr(Win|Good Birth) - Pr(Win|Bad Birth)", side=2,line=3,cex=.75)
mtext("Years Since Last War", side=1,line=3,cex=.75)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.04),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Years Since Last Interstate War", side=1,line=3,cex=.75)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.04),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Years Since Last Civil War", side=1,line=3,cex=.75)



}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.15, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black","gray"),
        lty=c(2,-1),pch=c(-1,15),ncol=1)









########################################
## Residualization
########################################


## War
# Laptop
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D3/Analysis/Models/Selection/Residualization/War/SimWarProb.dta")


## Interstate War
# Laptop
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D3/Analysis/Models/Selection/Residualization/ISWar/SimISWarProb.dta")



## Civil War
# Laptop
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D3/Analysis/Models/Selection/Residualization/CWar/SimCWarProb.dta")



op <- par(mfrow = c(1,3), oma=c(5,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.07),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.02,.04))
mtext("Pr(Win|Good Birth) - Pr(Win|Bad Birth)", side=2,line=3,cex=.75)
mtext("Years Since Last War", side=1,line=3,cex=.75)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.07),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.03,.06))
mtext("Years Since Last Interstate War", side=1,line=3,cex=.75)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=3,lwd=2,col="black",ylim=c(-.005,.07),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.5,.5,.5,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(0,0.03,.06))
mtext("Years Since Last Civil War", side=1,line=3,cex=.75)



}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.15, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black","gray"),
        lty=c(2,-1),pch=c(-1,15),ncol=1)











###########################################################
####  Time Periods
###########################################################




## Legacy
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/TimePeriods/War/SimWarProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/TimePeriods/ISWar/SimISWarProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/TimePeriods/CWar/SimCWarProb.dta")



op <- par(mfrow = c(1,3), oma=c(4,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Pr(Good Birth) - Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column A:  War", side=3,line=2,cex=1)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column B: Interstate War", side=3,line=2,cex=1)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column C: Civil War", side=3,line=2,cex=1)

}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1.75,-.175, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black",rgb(.25,.25,.25,.25)),
       lty=c(1,-1),pch=c(-1,15),ncol=2)





###########################################################
####  GDP per capita
###########################################################




## Legacy
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/GDPpc/War/SimWarProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/GDPpc/ISWar/SimISWarProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/GDPpc/CWar/SimCWarProb.dta")
cwarprob2 <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/NonRandomMissing/CWar/SimCWarProb.dta")



op <- par(mfrow = c(2,2), oma=c(4,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.2),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Pr(Good Birth) - Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column A:  War", side=3,line=2,cex=1)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.2),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column B: Interstate War", side=3,line=2,cex=1)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.2),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Pr(Good Birth) - Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column C: Civil War", side=3,line=2,cex=1)


#### Civil War

plot(cwarprob2$ruler,cwarprob2$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.2),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob2$ruler, rev(cwarprob2$ruler)),
        y = c(cwarprob2$diff_lo, rev(cwarprob2$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column C: Civil War, No GDPpc", side=3,line=2,cex=1)


}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1,-.5, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black",rgb(.25,.25,.25,.25)),
       lty=c(1,-1),pch=c(-1,15),ncol=2)








###########################################################
####  Population
###########################################################




## Legacy
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/Population/War/SimWarProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/Population/ISWar/SimISWarProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/Population/CWar/SimCWarProb.dta")



op <- par(mfrow = c(1,3), oma=c(4,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Pr(Good Birth) - Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column A:  War", side=3,line=2,cex=1)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column B: Interstate War", side=3,line=2,cex=1)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column C: Civil War", side=3,line=2,cex=1)

}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1.75,-.175, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black",rgb(.25,.25,.25,.25)),
       lty=c(1,-1),pch=c(-1,15),ncol=2)




###########################################################
####  Alternative Measure of Age
###########################################################




## Legacy
warprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/AltAge/War/SimWarProb.dta")
iswarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/AltAge/ISWar/SimISWarProb.dta")
cwarprob <- read.dta("/Users/Jeff/Dropbox/BirthLegaciesConflict/D5/Analysis/Models/AltAge/CWar/SimCWarProb.dta")



op <- par(mfrow = c(1,3), oma=c(4,2,0,0))

{

#### War

plot(warprob$ruler,warprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(warprob$ruler, rev(warprob$ruler)),
        y = c(warprob$diff_lo, rev(warprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Pr(Good Birth) - Pr(Bad Birth)", side=2,line=3,cex=1)
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column A:  War", side=3,line=2,cex=1)


#### Interstate War

plot(iswarprob$ruler,iswarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(iswarprob$ruler, rev(iswarprob$ruler)),
        y = c(iswarprob$diff_lo, rev(iswarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column B: Interstate War", side=3,line=2,cex=1)


#### Civil War

plot(cwarprob$ruler,cwarprob$diff_hat,type="l",lty=1,lwd=2,col="black",ylim=c(-.1,.1),xlim=c(0,50),yaxt="n",xaxt="n", xlab="", ylab="")
polygon(x=c(cwarprob$ruler, rev(cwarprob$ruler)),
        y = c(cwarprob$diff_lo, rev(cwarprob$diff_hi)),
        col=rgb(.25,.25,.25,.25), border=NA)
abline(h=0,col="black",lty=1)
axis(1, at=c(0,10,20,30,40,50))
axis(2, at=c(-.1,0,.1))
mtext("Years Since Last War", side=1,line=3,cex=1)
mtext("Column C: Civil War", side=3,line=2,cex=1)

}


op <- par(usr=c(0,1,0,1), # Reset the coordinates
          xpd=NA)

legend(-1.75,-.175, c("Difference","95% Confidence Interval"), bty="n", cex=1,col=c("black",rgb(.25,.25,.25,.25)),
       lty=c(1,-1),pch=c(-1,15),ncol=2)




######################################
##  Code for Graphing Negative Binomial Results
##  is located in the "Cross-Sectional Onset" and
##  "Cross-Sectional Outcomes" folders
######################################
